/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.group4.highschoolportal.teacher.backingBeans;

import com.group4.controller.CourseFacade;
import com.group4.entity.Course;
import com.group4.entity.Teacher;
import com.group4.entity.User;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

/**
 *
 * @author José
 */
@ManagedBean
@RequestScoped
public class TeacherCoursesBackingBean implements Serializable {
    @EJB
    private CourseFacade courseDb;
    
    private List<Course> courses;
    
    private User user;
    
    private Teacher teacher;

    

    /** Creates a new instance of StudentCoursesBackingBean */
    public TeacherCoursesBackingBean() {
            HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
            teacher = (Teacher) session.getAttribute("user");
            courses = new ArrayList<Course>();
    }

    public List<Course> getCourses() {
        for (Course c : teacher.getList()) {
              courses.add(c);
        }
        return courses;
    }
    public void setCourses(List<Course> courses) {
        this.courses = courses;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Teacher getTeacher() {
        return teacher;
    }

    public void setTeacher(Teacher teacher) {
        this.teacher = teacher;
    }
    
}
